
      real*4 function mean(nd,v)
      real*4 v(*),sum,fnd
      integer nd,k

      if(nd.le.0)then
         mean=0.
      else if(nd.eq.1)then
         mean=v(1)
      else 
      sum=0.
      fnd=float(nd)
      do k=1,nd
         sum=sum+v(k)/fnd
      enddo
      mean=sum
      endif
      return
      end